package com.yeyuanqi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeyuanqi.dao.UserMapper;
import com.yeyuanqi.model.domain.User;
import com.yeyuanqi.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo<User> selectUserWithPage(Integer page, Integer count) {
        PageHelper.startPage(page,count);
        List<User> userList = userMapper.selectUserWithPage();
        PageInfo<User> pageInfo = new PageInfo<>(userList);
        return pageInfo;
    }

    @Override
    public int publishUser(User user) {
        int n = userMapper.publishUser(user) ;
        return n;
    }


    //删除用户
    @Override
    public void deleteUserWithId(int id) {
        userMapper.deleteUserWithId(id);

    }
}
